const key1 = 1;
const key2 = "test";
const key3 = true;
let key4 = {
    test: 1
};
let key5 = [1,2,3];

// const set = new Set([key1, key2, key3, key4, key5]);
// key4 = null;
// console.log(...set);    //打印为：1 test true { test: 1 } [ 1, 2, 3 ]，此时key4对应的set仍旧存在，没有被销毁，形成了内存泄漏


const weakSet = new WeakSet([key4, key5]);
console.log(weakSet.has(key5));     //打印true

key5 = null;

console.log(weakSet.has(key5));     //打印false